package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * @author 吴峰
 * @version v1.0
 * @date 2019/3/11 10:05
 * @since v1.0
 */
@Getter
public enum LimitChooseRangeTypeEnum {

    /**
     * 可选范围类型
     */
    CUSTOM(1,"custom", "enum.limitChooseRangeType.memo.custom"),

    RELY(2, "rely", "enum.limitChooseRangeType.memo.rely"),

    ALL(3, "rely", "enum.limitChooseRangeType.memo.all"),

    FILTER_ADMIN(4, "filterAdmin", "enum.limitChooseRangeType.memo.filterAdmin"),

    ;

    private Integer code;

    private String type;

    private String memo;

    LimitChooseRangeTypeEnum(Integer code, String type, String memo) {
        this.code = code;
        this.type = type;
        this.memo = memo;
    }

    public static LimitChooseRangeTypeEnum getByType(String type) {
        for (LimitChooseRangeTypeEnum limitChooseRangeTypeEnum : values()) {
            if (limitChooseRangeTypeEnum.getType().equals(type)) {
                return limitChooseRangeTypeEnum;
            }
        }
        return null;
    }

    public String getMemo() {
        return I18nMessageUtil.getMessage(memo);
    }
}
